﻿using System;

namespace TextEditor
{
   

    public class A_FontBold : A_Action
    {
        public override string ActionName()
        {
            return "bold";
        }

        public override int CheckState()
        {
            ZYTextChar preChar = base.myOwnerDocument.Content.GetPreChar();
            if (preChar != null)
            {
                return (preChar.FontBold ? 1 : 0);
            }
            return -1;
        }

        public override A_Action Clone()
        {
            A_FontBold bold = new A_FontBold();
            bold.BaseCloneFrom(this);
            return bold;
        }

        public override bool Execute()
        {
            ZYTextChar preChar = base.myOwnerDocument.Content.GetPreChar();
            if (preChar != null)
            {
                base.myOwnerDocument.SetSelectionFontBold(!preChar.FontBold);
            }
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }
    }
}

